package skill;

import org.bukkit.entity.Player;

import pluginMain.SP;
import skill.SkillBase;
import skill.SkillBase.SkillType;

public class Skill {
	private SkillBase skillBase;
	private int skillLevel;
	private Player effectPlayer;

	public Skill(Player _target, SkillBase _skill, int _level) {
		skillBase = _skill;
		skillLevel = _level;
		effectPlayer = _target;
	}

	public Player getPlayer() {
		return effectPlayer;
	}

	public SkillBase getSkillBase() {
		return skillBase;
	}

	public int getLevel() {
		return skillLevel;
	}

	public void setLevel(int Level) {
		if (skillBase.getSkillType() == SkillType.Health) {
			int h = Level - skillLevel;
			effectPlayer.setMaxHealth(effectPlayer.getMaxHealth() + (h * 0.1f));
		}
		skillLevel = Level;
		
	}

	public void setNextLevel() {
		SP.LOGCONSOLE(String.valueOf(getLevel()));
		setLevel(getLevel() + 1);
	}

	public int getNextLevelExp() {
		if (getLevel() < 16) {
			return (getLevel() + 1) * 15;
		} else if (getLevel() > 15 && getLevel() < 31) {
			return (int) ((1.5f * Math.pow(getLevel() + 1, 2))
					- (29.5 * (getLevel() + 1)) + 360);
		} else {
			return (int) ((3.5f * Math.pow(getLevel() + 1, 2))
					- (151.5 * (getLevel() + 1)) + 2220);
		}
	}
}
